package com.binest.myLikes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.myLikes.domain.MyLikes;
import com.binest.myLikes.service.IMyLikesService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 我的点赞Controller
 * 
 * @author wwd
 * @date 2024-01-30
 */
@RestController
@RequestMapping("/myLikes")
public class MyLikesController extends BaseController
{
    @Autowired
    private IMyLikesService myLikesService;

    /**
     * 查询我的点赞列表
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyLikes myLikes)
    {
        startPage();
        List<MyLikes> list = myLikesService.selectMyLikesList(myLikes);
        return getDataTable(list);
    }




    /**
     * 导出我的点赞列表
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:export')")
    @Log(title = "我的点赞", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyLikes myLikes)
    {
        List<MyLikes> list = myLikesService.selectMyLikesList(myLikes);
        ExcelUtil<MyLikes> util = new ExcelUtil<MyLikes>(MyLikes.class);
        util.exportExcel(response, list, "我的点赞数据");
    }

    /**
     * 获取我的点赞详细信息
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(myLikesService.selectMyLikesById(id));
    }

    /**
     * 新增我的点赞
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:add')")
    @Log(title = "我的点赞", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MyLikes myLikes)
    {
        return toAjax(myLikesService.insertMyLikes(myLikes));
    }

    /**
     * 修改我的点赞
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:edit')")
    @Log(title = "我的点赞", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody MyLikes myLikes)
    {
        return toAjax(myLikesService.updateMyLikes(myLikes));
    }

    /**
     * 删除我的点赞
     */
//    @PreAuthorize("@ss.hasPermi('myLikes:myLikes:remove')")
    @Log(title = "我的点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(myLikesService.deleteMyLikesByIds(ids));
    }
}
